package com.ruoyi.web.controller.laiqianba.dict;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.wrapper.MemberBaseInfoWrapper;
import com.ruoyi.web.wrapper.MemberSourceDictInfoWrapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.MemberSourceDictInfo;
import com.ruoyi.laiqianba.service.IMemberSourceDictInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户资质字典管理Controller
 * 
 * @author ruoyi
 * @date 2023-08-13
 */
@RestController
@RequestMapping("/dict/dictInfo")
public class MemberSourceDictInfoController extends BaseController
{
    @Autowired
    private IMemberSourceDictInfoService memberSourceDictInfoService;

    /**
     * 查询用户资质字典管理列表
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberSourceDictInfo memberSourceDictInfo)
    {

        List<Map<String, Object>> list = memberSourceDictInfoService.selectMemberSourceDictInfoMapList(memberSourceDictInfo);
        list = new MemberSourceDictInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 查询用户资质字典管理列表
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:taskList')")
    @GetMapping("/taskList")
    public TableDataInfo taskList(MemberSourceDictInfo memberSourceDictInfo)
    {
        List<Map<String, Object>> list = memberSourceDictInfoService.selectMemberSourceDictInfoTaskMapList(memberSourceDictInfo);
        list = new MemberSourceDictInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出用户资质字典管理列表
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:export')")
    @Log(title = "用户资质字典管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberSourceDictInfo memberSourceDictInfo)
    {
        List<MemberSourceDictInfo> list = memberSourceDictInfoService.selectMemberSourceDictInfoList(memberSourceDictInfo);
        ExcelUtil<MemberSourceDictInfo> util = new ExcelUtil<MemberSourceDictInfo>(MemberSourceDictInfo.class);
        util.exportExcel(response, list, "用户资质字典管理数据");
    }

    /**
     * 获取用户资质字典管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberSourceDictInfoService.selectMemberSourceDictInfoById(id));
    }

    /**
     * 新增用户资质字典管理
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:add')")
    @Log(title = "用户资质字典管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberSourceDictInfo memberSourceDictInfo)
    {
        return toAjax(memberSourceDictInfoService.insertMemberSourceDictInfo(memberSourceDictInfo));
    }

    /**
     * 修改用户资质字典管理
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:edit')")
    @Log(title = "用户资质字典管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberSourceDictInfo memberSourceDictInfo)
    {
        return toAjax(memberSourceDictInfoService.updateMemberSourceDictInfo(memberSourceDictInfo));
    }

    /**
     * 删除用户资质字典管理
     */
    @PreAuthorize("@ss.hasPermi('dict:dictInfo:remove')")
    @Log(title = "用户资质字典管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberSourceDictInfoService.deleteMemberSourceDictInfoByIds(ids));
    }
}
